﻿package mortal.game.view.copy.ChallengeCopy.newView
{
    import Message.DB.Tables.*;
    import com.mui.controls.*;
    import com.mui.display.*;
    import mortal.component.gconst.*;
    import mortal.game.resource.*;
    import mortal.game.resource.tableConfig.*;
    import mortal.game.view.common.*;

    public class ChallengeDicRender extends GCellRenderer
    {
        private var _btn:GLoadingButton;
        private var _selectBg:ScaleBitmap;

        public function ChallengeDicRender()
        {
            return;
        }// end function

        override protected function createDisposedChildrenImpl() : void
        {
            super.createDisposedChildrenImpl();
            this._btn = UIFactory.gLoadingButton("", 0, 0, 118, 34, this);
            this._selectBg = UIFactory.bg(-1, -2, 120, 40, this, ImagesConst.ForgingSelectBg);
            return;
        }// end function

        override protected function disposeImpl(param1:Boolean = true) : void
        {
            this._btn.dispose(param1);
            this._btn = null;
            this._selectBg.dispose(param1);
            this._selectBg = null;
            super.disposeImpl(param1);
            return;
        }// end function

        override public function set selected(param1:Boolean) : void
        {
            super.selected = param1;
            if (param1)
            {
                this._selectBg.visible = true;
            }
            else
            {
                this._selectBg.visible = false;
            }
            return;
        }// end function

        override public function set data(param1:Object) : void
        {
            var _loc_3:String = null;
            var _loc_6:int = 0;
            super.data = param1;
            var _loc_2:* = param1.index;
            switch(_loc_2)
            {
                case 0:
                {
                    _loc_3 = ResFileConst.ChallengeCopySampleBtn;
                    break;
                }
                case 1:
                {
                    _loc_3 = ResFileConst.ChallengeCopyNormalBtn;
                    break;
                }
                case 2:
                {
                    _loc_3 = ResFileConst.ChallengeCopyDifficultBtn;
                    break;
                }
                default:
                {
                    break;
                }
            }
            this._btn.styleName = _loc_3;
            this._btn.drawNow();
            var _loc_4:* = param1.tower;
            var _loc_5:* = ChallengeCopyConfig.instance.getDataByTowerAndSectionAndDif(_loc_4, 1 + _loc_2 * 4, 1);
            if (_loc_5)
            {
                _loc_6 = ChallengeUtil.isCanEnterStateByTChallenge(_loc_5);
                if (_loc_6 == -1)
                {
                    var _loc_7:Boolean = false;
                    this.mouseEnabled = false;
                    this.mouseChildren = _loc_7;
                    this._btn.filters = [FilterConst.colorFilter2];
                }
                else
                {
                    var _loc_7:Boolean = true;
                    this.mouseEnabled = true;
                    this.mouseChildren = _loc_7;
                    this._btn.filters = [];
                }
            }
            else
            {
                var _loc_7:Boolean = false;
                this.mouseEnabled = false;
                this.mouseChildren = _loc_7;
                this._btn.filters = [FilterConst.colorFilter2];
            }
            return;
        }// end function

    }
}
